package com.belano.alerts;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import com.belano.domain.Spittle;

@Service
public class AlertServiceImpl implements AlertService {

    @Autowired
    JmsTemplate jmsTemplate;

    @Override
    public void sendSpittleAlert(final Spittle spittle) {
        jmsTemplate.send(new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                return session.createObjectMessage(spittle);
            }
        });
    }

}
